﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

namespace DigDes.DSchool.SUPS.Web.UI
{
    /// <summary>
    /// Summary description for ImageHandler
    /// </summary>
    public class ImageHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {

         
           byte[] image = DigDes.DSchool.SUPS.DataAccess.Database.CargoDAC.GetImageByID(context.Request.QueryString["CargoID"]);
           context.Response.ContentType = "image/jpeg";
            if (image != null)
            {
               context.Response.BinaryWrite(image);
            }
            else
           {
               context.Response.ContentType = "text/plain";
               context.Response.Write("No image of this cargo!");
           }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}